package com.zcc.thread;

public class Rabbit implements Runnable {
    @Override
    public void run() {
        int s = 0;
        for (int i = 0; i < 1000; i++) {
            s = s + 2;
            if (s % 10 == 0) {
                System.out.println(Thread.currentThread().getName() + "跑了" + s + "米");
            }
            if (s > 600&&i<=400) {
                try {
                    Thread.sleep(100);
                    s = s - 2;
                    System.out.println("兔子在睡觉");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            if (s==1000) {
                System.out.println("兔子到了终点");
                break;
            }
        }
    }
}
